#include "PointLight.h"

using namespace GalliumEngine;

PointLight::PointLight(void) : Light()
{
	position = Vector3(0.0f,0.0f,0.0f);
	attenuation = Attenuation(0.0f,0.0f,1.0f);

	params.push_back(BindParams("coord",BindType::BINDTYPE_ATTRIBUTE));
	params.push_back(BindParams("colour",BindType::BINDTYPE_UNIFORM));

	shader = ResourceManager::getInstance()->loadShader("PointLightShader",
		"Resources/Shaders/LightVertexShader.glsl","","Resources/Shaders/LightFragmentShader.glsl",params);
}

PointLight::PointLight(Vector3 _position, Colour _colour) : Light(_colour)
{
	position = _position;
	attenuation = Attenuation(0.0f,0.0f,1.0f);

	params.push_back(BindParams("coord",BindType::BINDTYPE_ATTRIBUTE));
	params.push_back(BindParams("colour",BindType::BINDTYPE_UNIFORM));

	shader = ResourceManager::getInstance()->loadShader("PointLightShader",
		"Resources/Shaders/LightVertexShader.glsl","","Resources/Shaders/LightFragmentShader.glsl",params);
}

PointLight::PointLight(Vector3 _position, Colour _colour, Attenuation _attenuation)
{
	position = _position;
	attenuation = _attenuation;

	params.push_back(BindParams("coord",BindType::BINDTYPE_ATTRIBUTE));
	params.push_back(BindParams("colour",BindType::BINDTYPE_UNIFORM));

	shader = ResourceManager::getInstance()->loadShader("PointLightShader",
		"Resources/Shaders/LightVertexShader.glsl","","Resources/Shaders/LightFragmentShader.glsl",params);
}

PointLight::~PointLight(void)
{
}

void PointLight::setLightPosition(Vector3 _position)
{
	position = _position;
}

Vector3 PointLight::getLightPosition()
{
	return position;
}

void PointLight::setLightAttenuation(Attenuation _attenuation)
{
	attenuation = _attenuation;
}

Attenuation PointLight::getLightAttenuation()
{
	return attenuation;
}

void PointLight::draw()
{
	shader->begin();

	glColor3f(this->getLightColour().getR(),this->getLightColour().getG(),this->getLightColour().getB());

	glBegin(GL_POINTS);
		glVertexAttrib3f((*shader)["coord"],position[0],position[1],position[2]);
	glEnd();

	shader->end();
}
